<template>
      <el-form ref="form" :model="loginBody" label-width="120px">
        <el-form-item label="用户名">
          <el-input v-model="loginBody.username"></el-input>
        </el-form-item>
        <el-form-item label="密码">
          <el-input v-model="loginBody.password"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="onSubmit">登录</el-button>
        </el-form-item>
      </el-form>
</template>
<script setup lang="ts">
import { useStore } from "../store/user";
import { useRouter } from 'vue-router'
import { ElMessage } from 'element-plus';
import { reactive } from "vue";

const user = useStore()
const router = useRouter()

export interface LoginBody {
  username: string | number,
  password: string | number,
}

const loginBody = reactive({
  username: 'root',
  password: '123456',
})
const onSubmit = () => {

  user.Login(loginBody).then((response) => {
   console.log("🚀 ~ file: Login.vue ~ line 40 ~ user.Login ~ response", response)
   ElMessage.success('登陆成功');
    console.log('跳转到首页')
    router.push('/')
  })
}
</script>

